package huff;

public class Test {

	public static void main(String[] args) {
		int n=8;
		HaffmanTree myHaff = new HaffmanTree(n);
		int[] weight= {5,25,3,6,10,11,36,4};
		HaffNode[] node = new HaffNode[2*n+1];
		Code[] haffCode=new Code[n];
		myHaff.haffman(weight, node);
		myHaff.haffmanCode(node, haffCode);
		for(int i=0;i<n;i++) {
			System.out.print("weight="+haffCode[i].weight+" "+"code=");
			for(int j=haffCode[i].start+1;j<n;j++)
				System.out.print(haffCode[i].bit[j]);
			System.out.println();
		}

	}

}
